<?php

namespace App\Model;

//use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    // 软删除字段
    public $dates = ['deleted_at'];

    // 允许显示的字段
    protected $fillable = ['id','name','admin_id','created_at','updated_at'];

    static public function _validate(){
        return array(
            'name'=>'max:32'
        );
    }

    static public function role_create($data){
        $data = self::validate($data);
        if(!$data['status']){
            return $data;
        }
        $data = $data['data'];
        $data['admin_id'] = auth()->user()->id;
        if(self::create($data)){
            return Json::success('添加成功');
        }else{
            return Json::error('添加失败');
        }
    }

}
